<template>
    <el-button color="#da9233" @click="insertCart">加入购物车</el-button>
</template>

<script setup>
import { insertGoodsToCart } from '@/apis/cart'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ref, watch } from 'vue'
const router = useRouter()
const route = useRoute()
const props = defineProps({
    count: {},
})
// 加入购物车
const insertCart = () => {
    insertGoodsToCart({ id: route.params.gid, count: props.count }).then(
        res => {
            ElMessage({
                message: '添加购物车成功！',
                type: 'success',
            })
        }
    )
}
</script>

<style lang="scss" scoped></style>
